﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Dormsystem
{
    public partial class ChangePassword : Form
    {
        public ChangePassword()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtPWD1.Text != txtPWD2.Text)
            {
                MessageBox.Show("两次输入不一致");
                return;
            }
            string username = lblUserName.Text;
            string password = txtPWD1.Text;

            string sql = string.Format("update userinfo set password = '{0}' where username='{1}'", password, username);

            int result = Convert.ToInt32(DB.ExcuteSQL(sql));

            if (result>0)
            {
                MessageBox.Show("修改成功");
            }

            this.DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }
    }
}
